// 递归实现
const flatter = (arr) => {
    let res=[];
    arr.forEach(num => {
        if(Array.isArray(num)){
            // res = res.concat(flatter(num))
            res = [...res, ...flatter(num)]
        } else {
            res.push(num);
        }
    })
    return res;
}

console.log(flatter([1,2,[3,4,[5,6]]]))